#include "hintview.h"
#include <QMouseEvent>
#include "toolkit.h"
#include <QLocale>
#include "item/imageitem.h"

HintView::HintView(QWidget *parent) :
    QGraphicsView(parent)
{
    m_Scene = new QGraphicsScene(this);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setScene(m_Scene);
    m_Scene->setSceneRect(0.0, 0.0, 640.0, 360.0);
    setGeometry(0.0,0.0,640.0,360.0);

    switch(ToolKit::m_language)
    {
    case QLocale::Chinese:
    {
        m_bgItem = new ImageItem(QImage(":/image/hint/hint1.png"),
                                 QRect(QPoint(0,0),QImage(":/image/hint/hint1.png").size()));
    }
        break;
    case QLocale::HongKong:
    case QLocale::Taiwan:
    {
        m_bgItem = new ImageItem(QImage(":/image/hint/hint2.png"),
                                 QRect(QPoint(0,0),QImage(":/image/hint/hint2.png").size()));
    }
        break;
    default:
    {
        m_bgItem = new ImageItem(QImage(":/image/hint/hint3.png"),
                                 QRect(QPoint(0,0),QImage(":/image/hint/hint3.png").size()));
    }
        break;
    }
    m_bgItem->setPos(0.0,0.0);
    m_bgItem->setZValue(0.0);
    m_Scene->addItem(m_bgItem);
}

void HintView::mousePressEvent(QMouseEvent *event)
{
    if(QRectF(290.0,210.0,60.0,60.0).contains(event->pos()))
    {
        if(ToolKit::m_bVoice)
            ToolKit::playSound(2);

        if(m_bGameBack)
            emit hint(2);
        else
            emit hint(1);
    }
    else if(QRectF(390.0,210.0,60.0,60.0).contains(event->pos()))
    {
        if(ToolKit::m_bVoice)
            ToolKit::playSound(2);

        emit hint(0);
    }
}
